﻿using System;
using System.Collections.Generic;
using System.Threading;
using System.Globalization;

namespace VisualPureBasicIDE.CoreGUI.OptionPanels
{
    public partial class Environment_InternationalPanel : OptionsPanel
    {
        public Environment_InternationalPanel()
        {
            InitializeComponent();

            comboBoxLanguage.Items.Clear();
            var cultures = CultureInfo.GetCultures(CultureTypes.FrameworkCultures);
            Array.Sort(cultures, new CultureComparer());
            foreach (var culture in cultures)
                comboBoxLanguage.Items.Add(culture.EnglishName);
            comboBoxLanguage.Text = Thread.CurrentThread.CurrentUICulture.EnglishName;
        }
    }

    /// <summary>
    /// Comparison class for cultures
    /// </summary>
    internal class CultureComparer : IComparer<CultureInfo>
    {
        /// <summary>
        /// Compares the names of two cultures
        /// </summary>
        public int Compare(CultureInfo x, CultureInfo y)
        {
            return x.EnglishName.CompareTo(y.EnglishName);
        }
    }
}